import request from './request'
import type {ILoginInf} from "@/interface/loginInf.ts";

// interface loginParams {
//   username: string
//   password: string
// }

interface sendCodeParams {
  email: string
}

//获取验证码
interface loginWithCodeParams extends sendCodeParams {
  code: string
}

//登录
const userLogin = (data: ILoginInf) => {
  const res = request({
    url: '/login',
    method: 'post',
    data: data,
  });
  console.log("+++++++++++++++++++++")
  res.then((response) => {
    console.log(response)
  })
  console.log("+++++++++++++++++++++")

  return res;
}

// 发送验证吗
const sendCodeFunc = (data: sendCodeParams) => {
  console.log(data)
  return request({
    url: '/sendCode',
    method: 'post',
    data: data,
  });
}

//短信验证吗登录

const loginWithCode = (data: loginWithCodeParams) => {
  console.log(data)
  return request({
    url: '/loginWithCode',
    method: 'post',
    data: data,

  });
}

export {
  userLogin,
  loginWithCode,
  sendCodeFunc
}
